﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Baosight.ZNH.ZMCommon;
using Baosight.Platform.Core.UI.Controls;
using Baosight.Platform.Core.ServiceModel;

namespace Baosight.ZNH.ZMCE.UI
{
    public partial class ZMCEF0 : EFViewCmes
    {
        private EFTreeItem item;    //记录选中的树节点
        public ZMCEF0()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(ZMCEF0_Loaded);
        }
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ZMCEF0_Loaded(object sender, RoutedEventArgs e)
        {
            this.tree.Refresh();

        }
        /// <summary>
        /// 选中树节点，导航右侧的页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tree_Selected(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            item = this.tree.SelectedItems[0] as EFTreeItem;

            Dictionary<string, string> args = new Dictionary<string, string>();
            string toencode = item.ItemObject.GetType().GetProperty("toencode").GetValue(item.ItemObject, null) as string;
            args.Add("fdToencode", toencode);
            this.container.LoadView("ZMCEF1", args);
        }

        /// <summary>
        /// 第一次进入页面时选中树的根节点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tree_ItemPrepared(object sender, Telerik.Windows.Controls.RadTreeViewItemPreparedEventArgs e)
        {
            if (e.PreparedItem == null)
            {
                return;
            }
            EFTreeItem treeItem = e.PreparedItem as EFTreeItem;
            if (treeItem.Level == 0)
            {
                this.tree.SelectedItem = treeItem;
            }
        }

    }
}
